package com.powervision.stateflowsimple

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

/**
 * @auth: njb
 * @date: 2021/12/7 17:37
 * @desc: 描述
 */
@ExperimentalCoroutinesApi
class MainViewModel : ViewModel() {

    private val mutableStateFlow = MutableStateFlow("stateFlow")
    val stateFlow: StateFlow<String> = mutableStateFlow

    fun setData(data: String) {
        mutableStateFlow.value = data
    }
}